#ifndef _table
#define _table
#include "link.h"

#include <iostream>
/*
#if defined(GENERIC)
class Table {
  // Students should write this class

 public:
  ostream & Print(ostream &os) const;
};
#endif
*/
#include<map>
using namespace std;
class RoutingMessage;
#if defined(LINKSTATE)
class TopoLink{
public:
	int cost;
	int age;
	int distance;
	bool used;
	bool inSet;
	TopoLink(){
		cost = -1;
		age = 0;
		distance = -1;
		used = false;
		inSet = false;
	};
	TopoLink(int c, int a){
		cost = c;
		age = a;
		distance = -1;
		used = false;
		inSet = false;
	}


};
class  TopologyTable{
	ostream & Print(ostream &os) const;

public:
	bool updated;
	map<int, map<int, TopoLink> > m;
	TopologyTable(){updated = true;};
	bool updateTable(const RoutingMessage * message);
	int updateLink(const Link *l);
	void printTable();
	void find(int *src, int *dest);
};
class Table {
  // Students should write this class
 public:
  ostream & Print(ostream &os) const;
};
#endif

#if defined(DISTANCEVECTOR)

#include <deque>

class BestHop{
	public:
	double cost;
	int hop;
	BestHop(){
		cost = -1;
		hop = -1;
	}
};

class Table {
 public:
	map<int,BestHop> shortest;
	map<int,map<int,double> > dist;
	bool updateTable(const RoutingMessage * message);
	bool updateLink(const Link *l);
	void printFull(); // imp
	void printShortest(); // imp
	bool exists(int dest);
  ostream & Print(ostream &os) const;
};
#endif

inline ostream & operator<<(ostream &os, const Table &t) { return t.Print(os);}

#endif
